<template>
    <view class="bills-info">
        <view class="info-content">
            <view class="b-info">
                <!-- 订单详细数据组件 -->
                <orderinfo
                    :orderInfoData="orderInfos"
                    :customer_info="customer_info"
                    :address="address"
                    :setShippType="setShippType"
                    :isNotData="isNotData"
                    :isShowOrder="true"
                    :md="md"
                    @openConsult="openConsult"
                    @showCustmInfo="showCustmInfo"
                    @feeInfo="feeInfo"
                    @ogisticsFun="ogisticsFun"
                >
                </orderinfo>
                <view class="overflow-box" v-show="!isNotData">
                    <!-- 订单详细列表组件 -->
                    <orderlist
                        :orderInfo="orderInfos.goods_ls"
                        :md="md"
                        :orderInfos="orderInfos"
                        @updateFun="updatainfo"
                    ></orderlist>
                </view>
                <orderflexbottom
                    ref="loadBtnData"
                    :btnArr="btnArr"
                    @orderOpration="orderOpration"
                    v-show="!isNotData"
                ></orderflexbottom>
                <!-- 订单底部操作按钮组件 -->
                <empty class="empty-p-style" v-if="isNotData"></empty>
            </view>
            <operate ref="toggleItem" :md="md"></operate>
            <consult ref="consult" title="协商记录"></consult>
            <popInputWin ref="popInputWin"></popInputWin>
            <!-- 收款，退款窗口 -->
            <payMent ref="payMent"></payMent>
            <!-- 备注详情 -->
            <noteMask
                ref="noteMask"
                :newNoteArr="newNoteArr"
                :orderInfos="orderInfos"
                :md="md"
                @updateFun="updatainfo"
            ></noteMask>
            <!-- 费用列表 -->
            <outlayList ref="outlayList"></outlayList>
            <!-- 打印选择 -->
            <popPrintWin ref="popPrintWin" @printType="printType"></popPrintWin>

            <!-- 二维码支付 -->
            <payQrcode ref="payQrcode"></payQrcode>

            <!-- 云单改价 -->
            <changePriceWin
                ref="changePriceWin"
                @changePrice="changePrice"
            ></changePriceWin>

            <view class="c-info" v-show="showInfo">
                <customerInfo
                    :orderInfoData="orderInfos"
                    :address="address"
                    :newNoteArr="newNoteArr"
                    :customer_info="customer_info"
                    :md="md"
                    @openNoteMask="showNoteMask"
                    @showCustmInfo="showCustmInfo"
                ></customerInfo>
            </view>
            <selectShopList
                :shopList="shopList"
                ref="myShopList"
            ></selectShopList>
            <el-dialog
                title="添加物流信息"
                :visible.sync="iseditLogistics"
                width="430px"
                top="11vh"
                :close-on-click-modal="false"
            >
                <view class="logistics-cloud">
                    <view class="odd-numbers">
                        <text>单号： {{ orderInfos.no }}</text>
                    </view>
                    <view class="info-form">
                        <el-form
                            ref="ogisticsForm"
                            :model="ogisticsForm"
                            label-width="68px"
                            :rules="rules"
                            :hide-required-asterisk="true"
                        >
                            <el-form-item label="物流单号" prop="kdno">
                                <el-input
                                    v-model="ogisticsForm.kdno"
                                    placeholder="请输入物流单号"
                                    class="w-300"
                                ></el-input>
                            </el-form-item>

                            <el-form-item label="承运单位" prop="cpcode">
                                <el-select
                                    v-model="ogisticsForm.cpcode"
                                    placeholder="可按快递首字母搜索"
                                    class="w-300"
                                    v-loadMore="loadFun"
                                    filterable
                                    :filter-method="changelistFun"
                                >
                                    <el-option
                                        v-for="item in carriageData"
                                        :key="item.cpcode"
                                        :label="item.cpname"
                                        :value="item.cpcode"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="备注">
                                <el-input
                                    type="textarea"
                                    :autosize="{ minRows: 2, maxRows: 8 }"
                                    v-model="ogisticsForm.txt"
                                    placeholder="输入备注(200)"
                                    class="w-300"
                                    maxlength="200"
                                    show-word-limit
                                ></el-input>
                            </el-form-item>
                        </el-form>
                    </view>
                </view>

                <text slot="footer" class="dialog-footer">
                    <el-button @click="iseditLogistics = false"
                        >取 消</el-button
                    >
                    <el-button
                        type="primary"
                        @click="editlogisticsFun"
                        :loading="is_butloa"
                        >确 定</el-button
                    >
                </text></el-dialog
            >
            <el-dialog
                title="物流信息"
                :visible.sync="isogisticsInfo"
                width="80%"
                top="11vh"
                :close-on-click-modal="false"
                v-loading="tableloading"
            >
                <view class="isogisticsInfo-box">
                    <view class="table-box">
                        <el-table
                            :data="ogisticsInfolist"
                            align="left"
                            stripe
                            class="supplierList"
                            style="width: 100%"
                            @row-click="trackLogistics"
                        >
                            <el-table-column
                                align="left"
                                prop="cpname"
                                label="承运人"
                                width="100"
                            >
                            </el-table-column>
                            <el-table-column
                                align="center"
                                prop="kdno"
                                label="运单号"
                                width="180"
                            >
                            </el-table-column>
                            <el-table-column
                                align="center"
                                prop="uname_cp"
                                label="操作人"
                                width="100"
                            >
                            </el-table-column>
                            <el-table-column
                                align="center"
                                prop="etime_txt"
                                label="时间"
                                width="180"
                            >
                            </el-table-column>
                            <el-table-column
                                align="center"
                                prop="txt"
                                label="备注"
                            >
                            </el-table-column>

                            <el-table-column
                                align="right"
                                label="操作"
                                width="180"
                            >
                                <template slot-scope="scope">
                                    <view class="operation-but">
                                        <el-button
                                            type="primary"
                                            size="mini"
                                            @click.stop="
                                                operationInfoFun('1', scope.row)
                                            "
                                            >编辑</el-button
                                        >
                                        <el-button
                                            type="danger"
                                            size="mini"
                                            @click.stop="
                                                operationInfoFun('2', scope.row)
                                            "
                                            :loading="is_butloa"
                                            >删除</el-button
                                        >
                                    </view>
                                </template>
                            </el-table-column>
                        </el-table>
                    </view>
                </view>
            </el-dialog>
            <el-dialog
                title="物流详情"
                :visible.sync="istrackLogistics"
                width="400px"
                top="11vh"
                :close-on-click-modal="false"
            >
                <view class="web-view-box">
                    <iframe class="iframe-info" :src="logistics_html"> </iframe>
                </view>
            </el-dialog>
        </view>
    </view>
</template>

<script>
import ordertoptitle from "./OrderTopTitle.vue";
import orderinfo from "../comm/OrderInfo.vue";
import orderlist from "./OrderList.vue";
import orderflexbottom from "./OrderFixedBottom.vue";
import customerInfo from "./customerInfo.vue";

import empty from "../comm/empty.vue";

import config from "../../js/conf/Config.js";
import staticConst from "../../js/const/StaticConst.js";
import cmd from "../../js/Cmd.js";
import util from "../../js/util/Util.js";

import btnsContrl from "../../js/BtnsContrl.js";

import operate from "./operateMask.vue";
import popInputWin from "../comm/PopInputWin.vue";
import consult from "./ConsultMask.vue";

import selectShopList from "../comm/SelectShopList.vue";

import outlayList from "../comm/OutlayList.vue";

import lang from "../../js/conf/Lang.js";

import payMent from "./PaymentMask.vue";

import noteMask from "./noteMask.vue";

import eventCtrl from "../../js/event/EventCtrl.js";

import https from "../../js/https/Https.js";

import printCtrl from "../../js/print/PrintCtrl.js";

import popPrintWin from "../comm/PopPrintWin.vue";

import payQrcode from "../comm/PayQrcode.vue";

import changePriceWin from "../comm/ChangePriceWin.vue";

let printSize = null;
let pageNo = 0;
export default {
    components: {
        ordertoptitle,
        orderinfo,
        orderlist,
        orderflexbottom,
        customerInfo,
        operate,
        selectShopList,
        popInputWin,
        consult,
        payMent,
        noteMask,
        empty,
        outlayList,
        popPrintWin,
        payQrcode,
        changePriceWin,
    },
    data() {
        return {
            title: "销售单详情",
            orderInfos: {},
            customer_info: {},
            address: {},
            bottomBtn: [],
            orderId: null,
            type: null,
            printSize: 241,
            showInfo: false,
            btnArr: [],
            operateLs: [],
            shopList: [],
            storeList: [],
            billListPageId: staticConst.BILLS_CLOUD,
            newNoteArr: [],
            setShippType: null, //运费
            isNotData: false, //没有数据
            isHasYunPrint: false, //是否有云打印
            md: staticConst.MD_DJ,
            expressOperation: "1",
            iseditLogistics: false,
            is_butloa: false,
            tableloading: false,
            kwvalue: "",
            carriageData: [],
            ogisticsInfolist: [],
            pfrom: 0,
            is_soll: false,
            isogisticsInfo: false,
            istrackLogistics: false,
            logistics_html: "",
            ogisticsForm: {
                kdno: "",
                cpcode: "",
                txt: "",
            },
            webviewStyles: {
                progress: {
                    color: "#FF3333",
                },
            },
            rules: {
                kdno: [
                    {
                        required: true,
                        message: "请输入物流编号",
                        trigger: "blur",
                    },
                    {
                        pattern: /^[a-zA-Z0-9_]{0,}$/,
                        message: "物流编号格式错误",
                        trigger: "blur",
                    },
                ],
                cpcode: [
                    {
                        required: true,
                        message: "请选择承运单位",
                        trigger: "change",
                    },
                ],
            },
        };
    },

    async created() {
        await this.getShopList();
        await this.getStoreList();
        await this.getYunPrintList();
    },
    methods: {
        // 打开物流轨迹
        trackLogistics(option) {
            this.istrackLogistics = true;
            this.logistics_html = `${config.OSS_HOST}static/gzh/imiyun/index.html#/pages/guest/logistics-info?type=1&md=xs&kdId=${option.kdno}&odid=${option.odid}&cpid=${option.cpid}&cpcode=${option.cpcode}`;
        },
        // 初始化物流编辑弹框的表单
        initogistics() {
            this.ogisticsForm = {
                kdno: "",
                cpcode: "",
                txt: "",
            };
            this.carriageData = [];
            this.pfrom = 0;
            this.getdklistFun();
        },
        // 已选物流列表操作
        operationInfoFun(type, val) {
            if (type == 1) {
                this.editedData = val;
                this.iseditLogistics = true;
                this.expressOperation = "2";
                this.initogistics();
            } else {
                this.$confirm("确定删除该物流吗?", "删除", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning",
                }).then(() => {
                    const _this = this;
                    let data = {
                        act: "del",
                        id: val.id,
                    };
                    _this.is_butloa = true;
                    https.setkdnoSave(data, back);
                    function back(res) {
                        if (!res) return;
                        _this.is_butloa = false;
                        _this.ogisticsInfolist.map((v, i) => {
                            if (v.id == val.id) {
                                _this.ogisticsInfolist.splice(i, 1);
                                _this.orderInfos.kuaidi_info.num =
                                    _this.ogisticsInfolist.length;
                            }
                        });
                    }
                });
            }
        },
        ogisticsFun() {
            this.isogisticsInfo = true;
            const data = {
                type: this.orderInfos.type,
                odid: this.orderInfos.id,
                md: "xs",
            };
            const _this = this;
            _this.tableloading = true;
            https.getkdnoList(data, back);
            function back(res) {
                _this.tableloading = false;
                _this.ogisticsInfolist = res.data.ls || [];
            }
        },

        // 物流公司下拉框搜索事件
        changelistFun(val) {
            this.kwvalue = val;
            this.carriageData = [];
            this.pfrom = 0;
            this.getdklistFun();
        },
        // 物流公司滚动加载事件
        loadFun() {
            if (this.is_soll) return;
            this.pfrom += 20;
            this.getdklistFun();
        },
        // 添加/编辑物流信息
        editlogisticsFun() {
            this.$refs["ogisticsForm"].validate((valid) => {
                if (valid) {
                    let data = {};
                    if (this.expressOperation == 1) {
                        // 新增提交的数据
                        data = {
                            act: "add",
                            md: "xs",
                            kdno: this.ogisticsForm.kdno,
                            cpcode: this.ogisticsForm.cpcode,
                            txt: this.ogisticsForm.txt,
                            type: this.orderInfos.type,
                            odid: this.orderInfos.id,
                        };
                    } else {
                        // 编辑提交的数据
                        data = {
                            act: "edt",
                            kdno: this.ogisticsForm.kdno,
                            cpcode: this.ogisticsForm.cpcode,
                            txt: this.ogisticsForm.txt,
                            id: this.editedData.id,
                        };
                    }
                    this.is_butloa = true;
                    const _this = this;
                    https.setkdnoSave(data, back);
                    function back(res) {
                        if (res != 1) return;
                        _this.$msg({ title: "保存成功" });
                        _this.is_butloa = false;
                        _this.iseditLogistics = false;
                        if (_this.expressOperation == 1) {
                            _this.updatainfo(_this.orderInfos);
                        } else {
                            // 更新编辑后的列表数据
                            _this.ogisticsFun();
                        }
                    }
                }
            });
        },
        // 获取物流公司列表
        async getdklistFun() {
            const param = {
                pfrom: this.pfrom,
                pnum: 20,
                type: "1",
                kw: this.kwvalue || undefined,
            };
            const res = await https.getdkList(param, true);
            if (res.data.ls) {
                if (this.editedData.cpcode) {
                    // 获取插入编辑时的物流公司数据
                    res.data.ls.map((v) => {
                        if (v.cpcode != this.editedData.cpcode) {
                            this.carriageData.push(v);
                        }
                    });
                    const bool = this.carriageData.some((v) => {
                        return v.cpcode === this.editedData.cpcode;
                    });
                    if (!bool) {
                        this.carriageData.unshift({
                            cpcode: this.editedData.cpcode,
                            cpname: this.editedData.cpname,
                        });
                    }
                    this.ogisticsForm = {
                        kdno: this.editedData.kdno,
                        cpcode: this.editedData.cpcode,
                        txt: this.editedData.txt,
                    };
                } else {
                    // 新增时插入物流公司数据
                    res.data.ls.map((v) => {
                        this.carriageData.push(v);
                    });
                }
            } else {
                this.is_soll = true;
            }
        },
        // 更新订单详情
        updatainfo(data) {
            const obj = {
                odid: data.id,
                type: data.type,
            };
            this.createdOrderInfo(obj);
        },
        /********打开费用详情********/
        feeInfo() {
            if (
                this.orderInfos &&
                this.orderInfos.fee_info &&
                this.orderInfos.fee_info.fee_ls
            ) {
                this.$refs.outlayList.show("show");
                let data = {};
                data.list = this.orderInfos.fee_info.fee_ls;
                data.fee_total = this.orderInfos.fee_total;
                data.amount_fee = this.orderInfos.amount_fee;
                this.$refs.outlayList.initData(data);
            }
        },

        openConsult() {
            let obj = {};
            obj.odid = this.orderInfos.id;
            this.$refs.consult.toggleBillsStateMask("show", obj);
        },

        /****获取是否有云打印列表******/
        getYunPrintList() {
            let that = this;
            let param = {};
            https.getPrintYunList(param, back);
            function back(data) {
                if (!data) return;
                if (data.status == 1) {
                    if (!data.data) return;
                    data = data.data;
                    if (data.ls && data.ls.length > 0) {
                        that.isHasYunPrint = true;
                    }
                }
            }
        },

        /**获取门店**/
        async getShopList() {
            let url = config.SHOP_LS;
            let param = {};
            param.ismy = 1;
            let res = await this.$api({ url: url, data: param });
            if (!res) return;
            if (res.status == 1) {
                if (!res.data) return;
                this.shopList = res.data;
            }
        },

        /**获取仓库列表***/
        async getStoreList() {
            let url = config.STORE_LS;
            let param = {};
            param.ismy = 1;
            param.md = staticConst.ORDER_XS;
            let res = await this.$api({ url: url, data: param });
            if (!res) return;
            if (res.status == 1) {
                if (!res.data) return;
                this.storeList = res.data;
            }
        },

        /***  付款记录&操作记录弹窗  **/
        onOperate(type) {
            let obj = {};
            obj.type = this.orderInfos.type;
            obj.odid = this.orderInfos.id;
            obj.activeType = type;
            if (this.orderInfos.type == 4) {
                obj.del = 1;
                obj.odid = this.orderInfos.odid;
                obj.type = this.orderInfos.type_12;
            }
            this.$refs.toggleItem.orderOprAndPay(obj);
        },

        /*** 获取单据详情数据    ORDER_INFO ***/
        async createdOrderInfo(data) {
            // 解锁操作
            this.btnArr = [];
            if (this.type && this.orderId) {
                this.unlockOrder(this.type, this.orderId);
            }
            if (data != null) {
                let url = config.ORDER_INFO;
                let param = {};
                this.type = param.type = data.type;
                this.orderId = param.odid = data.odid;
                let res = await this.$api({ url: url, data: param });
                if (!res) return;
                if (res.status == 1 && res.data) {
                    this.setShipp(res.data);
                    this.orderInfos = res.data;
                    this.newNoteArr = res.data.txt_ls || [];
                    this.customer_info = res.data.customer_info;
                    this.address = res.data.address;
                    this.btnArr = btnsContrl.btnsOrderHandler(res.data);
                    if (printSize == null) {
                        this.getPrintSize(this.orderInfos.cpid);
                    }
                    if (res.data.lock_txt) {
                        this.$msg({ title: res.data.lock_txt });
                    }
                    this.isNotData = false;
                } else {
                    this.isNotData = true;
                }
            } else {
                this.isNotData = true;
            }
        },

        /*** 设置运费 ***/
        setShipp(order) {
            if (order.amount_shipp > 0) {
                this.setShippType = order.amount_shipp;
            } else {
                if (order.sfee_type == 1) {
                    this.setShippType = "包邮";
                } else if (order.sfee_type == 3) {
                    this.setShippType = "到付";
                } else {
                    this.setShippType = order.amount_shipp;
                }
            }
        },

        /*** 显示备注详情 ***/
        showNoteMask() {
            this.$refs.noteMask.toggleBillsStateMask("show");
        },

        /***获取企业打印模板尺寸***/
        async getPrintSize(cpid) {
            printSize = printCtrl.printSize;
            if (printSize == 0) {
                //==0重新请求
                printCtrl.getPrintSize(cpid, back);
            }
            function back(data) {
                printSize = data;
            }
        },

        /*** 解锁单号   ORDER_ACT ***/
        async unlockOrder(type, odid) {
            let url = config.ORDER_ACT;
            let param = {};
            param.type = type;
            param.odid = odid;
            param.act = staticConst.UNLOCK;
            let res = await this.$api({ url: url, data: param });
        },

        /*** 打印操作   PRINT_PAGE ***/
        print() {
            if (this.orderId && this.orderInfos.cpid) {
                this.localPrint(); //本地打印
            }
        },

        printType(type) {
            if (type == 0) {
                this.doYunPrint();
            } else {
                this.localPrint(); //本地打印
            }
        },

        /*******本地打印********/
        localPrint() {
            let data = {};
            data.cpid = this.orderInfos.cpid;
            data.orderId = this.orderId;
            data.type = staticConst.ORDER_XS;
            data.type_od = this.orderInfos.type;
            if (printSize == staticConst.PRINT_SIZE_241) {
                //241模板
                data.url = config.PRINT_URL_1;
            } else if (printSize == staticConst.PRINT_SIZE_80) {
                //80模板
                data.url = config.PRINT_URL_2;
            }
			
			console.log("data===============:",data);
			
            printCtrl.print(data);
            this.printCount();
        },

        /***打印次数累计***/
        printCount() {
            let that = this;
            let url = config.PRINT_COUNT;
            let param = {};
            param.cpid = this.orderInfos.cpid;
            param.type = staticConst.ORDER_XS;
            param.odtype = this.orderInfos.type;
            param.odid = this.orderInfos.id;
            https.printCount(param, back);
            function back(data) {
                if (!data) return;
                if (data.status == 1) {
                    that.orderInfos.print++;
                }
            }
        },

        /****云打印*****/
        doYunPrint() {
            let that = this;
            let param = {};
            param.type = staticConst.ORDER_XS;
            param.type12 = this.orderInfos.type;
            param.cpid = this.orderInfos.cpid;
            param.odid = this.orderInfos.id;
            https.doYunPrint(param, back);
            function back(data) {
                if (!data) return;
                if (data.status == 1) {
                    if (!data.data) return;
                    console.log("doYunPrint().back():云打印成功！！！！");
                    that.$msg({ title: "提交云打印成功! 请稍等待..." });
                }
            }
        },

        /***关闭客户详情**/
        showCustmInfo() {
            this.showInfo = !this.showInfo;
            cmd.external(cmd.CMD_SHOW_MORE, this.showInfo);
        },

        /**单据操作***/
        orderOpration(act) {
            console.log('act============>',act);
            if (act === "kdno_add") {
                this.iseditLogistics = true;
                this.expressOperation = "1";
                this.editedData = {};
                this.initogistics();
            }
            if (act == "print") {
                // 打印
                console.log(
                    "this.isHasYunPrint===========:",
                    this.isHasYunPrint
                );
                if (this.isHasYunPrint) {
                    this.$refs.popPrintWin.show("show");
                } else {
                    this.print();
                }
            } else if (act == "del") {
                //删除
                let d = {};
                (d.content = "是否删除该单据？"), (d.showCancel = true);
                let obj = {};
                obj.act = act;
                obj.url = config.ORDER_ACT;
                d.data = obj;
                lang.showWin(d, callBack);
            } else if (act == "copy" || act == "return_ck" || act == "edt3") {
                //抄单,退货,编辑草稿
                this.coypReturnEditDirfet(act);
            } else if (act == "pay_in" || act == "pay_out") {
                //收款/退款
                this.toPay(act);
                //this.$refs.payMent.toggleBillsStateMask("show",{});
            } else if (act == "reject" || act == "edt") {
                //拒绝退货
                let obj = {};
                let d = [];
                obj.url = config.ORDER_RETURN_CK;
                obj.act = act == "edt" ? act : "tock";
                obj.id_ask = this.orderInfos.ask_rt.id;
                if (act == "reject") obj.status = 1;
                d.data = obj;
                d.title = "拒绝理由";
                d.callBack = ydReturnCallBack;
                this.$refs.popInputWin.toggleBillsStateMask("show", d);
            } else if (act == "agree") {
                //同意退货
                let d = {};
                (d.content = "确认同意退货吗？"), (d.showCancel = true);
                let obj = {};
                obj.act = "tock";
                obj.status = 2;
                obj.url = config.ORDER_RETURN_CK;
                d.data = obj;
                lang.showWin(d, ydReturnCallBack);
            } else if (act == "op_recoder") {
                //操作记录
                this.onOperate(1);
            } else if (act == "pay_recoder") {
                //付款记录
                this.onOperate(0);
            }else if (act == "return_record") {
                //退款记录
                this.onOperate(2);
            } else if (act == "scrap") {
                //作废
                let d = {};
                (d.content = "是否作废该单据？"), (d.showCancel = true);
                let obj = {};
                obj.act = act;
                obj.url = config.ORDER_ACT;
                if (this.billListPageId == staticConst.BILLS_CLOUD) {
                    //云单作废要选择门店
                    obj.data = this.shopList;
                    if (this.shopList.length > 1) {
                        obj.titleType = 0;
                        obj.callBack = callBack;
                        this.$refs.myShopList.toggleAboutStateMask("show", obj);
                    } else {
                        if (this.shopList.length == 1) {
                            obj.id = this.shopList[0].id;
                            d.data = obj;
                            lang.showWin(d, callBack);
                        }
                    }
                } else {
                    d.data = obj;
                    lang.showWin(d, callBack);
                }
            } else if (act == "store_out" || act == "store_in") {
                //出库
                let obj = {};
                obj.url = config.ORDER_ACT;
                obj.data = this.storeList;
                obj.titleType = 1;
                obj.act = act;
                obj.callBack = callBack;
                this.$refs.myShopList.toggleAboutStateMask("show", obj);
            } else if (act == "tock") {
                //确认云单
                let obj = {};
                obj.url = config.ORDER_ACT;
                obj.data = this.shopList;
                obj.titleType = 0;
                obj.act = act;
                obj.callBack = callBack;
                this.$refs.myShopList.toggleAboutStateMask("show", obj);
            } else if (act == "custom_add") {
                this.$emit("addNewCustom"); //这里有问题，应要绑定一个订单客户
            } else if (act == "chprice") {
                let obj = {};
                obj.amount_shipp = this.orderInfos.amount_shipp;
                obj.amount_zero = this.orderInfos.amount_zero;
                obj.amount_all = this.orderInfos.amount_all;
                obj.amount_od = this.orderInfos.amount_od;

                this.$refs.changePriceWin.show("show", obj);
            }

            let that = this;
            async function callBack(data) {
                if (
                    data.cancel &&
                    data.data &&
                    (data.data.act == "scrap" || data.data.act == "del")
                )
                    return; //点击取消作废
                let url = data.url;
                if (!url)
                    //兼容
                    url = data.data.url;
                let param = {};
                param.type = that.orderInfos.type;
                param.odid = that.orderInfos.id;
                param.act = data.act;
                if (!param.act)
                    //兼容
                    param.act = data.data.act;
                if (param.act == "tock" || param.act == "scrap") {
                    //确认云单
                    param.shopid = data.id;
                    if (!param.shopid)
                        //兼容
                        param.shopid = data.data.id;
                }

                if (param.act == "store_out" || param.act == "store_in")
                    //出库
                    param.storeid = data.id;
                let res = await that.$api({ url: url, data: param });
                if (!res) return;
                if (res.status == 1) {
                    that.$msg({ title: res.msg });
                    if (param.act == "store_out" || param.act == "store_in") {
                        that.storeOutHandler(param.act);
                        return;
                    }
                    that.type = null;
                    that.orderId = null;
                    uni.$emit(eventCtrl.ACTION_ORDER_EVENT, param.odid);
                }
            }

            /****云单退货申请****/
            async function ydReturnCallBack(data) {
                let url = data.url;
                if (!url) url = data.data.url;
                let param = {};
                param.act = data.act;
                if (!param.act) param.act = data.data.act;

                param.id_ask = that.orderInfos.ask_rt.id;
                if (data.status) param.status = data.status;
                if (param.act == "tock" && !param.status)
                    param.status = data.data.status;
                if (data.txt) param.txt_cp = data.txt;
                let res = await that.$api({ url: url, data: param });
                if (!res) return;
                if (res.status == 1) {
                    that.type = null;
                    that.orderId = null;
                    that.$msg({ title: res.msg });
                    if (
                        (param.act == "tock" && param.status == 2) ||
                        param.act == "agree"
                    ) {
                        uni.$emit(
                            eventCtrl.ACTION_ORDER_EVENT,
                            that.orderInfos.id
                        );
                    }
                    if (act == "reject" || act == "edt") {
                        let data = {};
                        data.id = that.orderInfos.id;
                        data.type = 2;
                        uni.$emit(eventCtrl.PAY_IN_AND_OUT_EVENT, data);
                    }
                }
            }
        },

        /******修改云单价格********/
        async changePrice(data) {
            let param = {};
            let that = this;
            let url = config.ORDER_ACT;
            param.act = "chprice";
            param.price_new = {};
            param.price_new.amount_zero = data.amount_zero;
            param.price_new.amount_shipp = data.amount_shipp;
            param.type = this.orderInfos.type;
            param.odid = this.orderInfos.id;
            let res = await this.$api({ url: url, data: param });
            if (!res) return;
            if (res.status == 1) {
                let obj = {};
                obj.type = param.type;
                obj.odid = param.odid;
                await this.createdOrderInfo(obj);
                this.$emit("changeYunBillPrice", this.orderInfos);
            }
        },

        /***出库处理***/
        storeOutHandler(act) {
            this.btnArr.splice(this.btnArr.length - 1, 1);
            this.orderInfos.status_act.status_send_txt =
                act == "store_out" ? "已出库" : "已入库";
        },

        /****topay（去收款/去退款）**/
        async toPay(act) {
            let that = this;
            let param = {};
            let url = config.ORDER_PAY;
            param.type = this.orderInfos.type;
            param.odid = this.orderInfos.id;
            param.act = "topay";
            let res = await this.$api({ url: url, data: param });
            if (!res) return;
            if (res.status == 1) {
                if (!res.data) return;
                let obj = {};
                obj = res.data;
                obj.act = act;
                obj.odid = this.orderInfos.id;
                obj.type = this.orderInfos.type;
                obj.callBack = topayAction;
                this.$refs.payMent.toggleBillsStateMask("show", obj);
            }

            async function topayAction(data) {
                console.log("data.payid=====:", data.payid);
                if (!data.payid || data.payid >= 1000) {
                    let param = data;
                    let url = config.ORDER_PAY;
                    let res = await that.$api({ url: url, data: param });
                    if (!res) return;
                    if (res.status == 1) {
                        that.$msg({ title: res.msg });
                        let obj = {};
                        let uData = {};
                        uData.id = obj.odid = that.orderInfos.id;
                        obj.type = that.orderInfos.type;
                        await that.createdOrderInfo(obj);
                        uData.status_pay_txt =
                            that.orderInfos.status_act.status_pay_txt;
                        uData.amount_notpay = that.orderInfos.amount_notpay;
                        uData.type = 1;
                        uni.$emit(eventCtrl.PAY_IN_AND_OUT_EVENT, uData);
                    }
                } else {
                    let obj = {};
                    obj.payType = data.paytype;
                    obj.objtype = staticConst.PAY_OBJ_01; //data.objtype;
                    obj.odid = data.odid;
                    obj.money_pay = data.amount_receive;
                    that.$refs.payQrcode.creatQrcode(obj);
                }
            }
        },

        /****抄单，退货，编辑草稿****/
        coypReturnEditDirfet(act) {
            let that = this;
            https.getCartInfo({}, back);
            function back(data) {
                if (!data) return;
                if (data.status == 1) {
                    data = data.data;
                    let has = false;
                    if (data.gd_ls) {
                        has = true;
                    }
                    that.cpReEdTip(act, has);
                }
            }
        },

        /*****抄单，退货，编辑草稿提示*****/
        cpReEdTip(act, has) {
            let msg = "";
            // if (has) msg = lang.commTipTxt;
            //1抄销售单、2抄退货单、3销售单退货、4草稿单编辑
            if (act == "copy") {
                msg = msg + lang.copyTipTxt;
            } else if (act == "return_ck") {
                msg = msg + lang.returnCkTipTxt;
            } else if (act == "edt3") {
                msg = msg + lang.editDirTipTxt;
            }
            let data = {};
            let that = this;
            data.content = msg;
            data.showCancel = true;
            lang.showWin(data, back);
            function back(res) {
                if (res.confirm) {
                    that.cpReEdAction(act);
                }
            }
        },

        /***请求抄单，退货，编辑草稿****/
        cpReEdAction(act) {
            let param = {};
            if (act == "copy") {
                if (this.orderInfos.type == 1) param.act = 1;
                else if (this.orderInfos.type == 2) param.act = 2;
            } else if (act == "return_ck") {
                param.act = 3;
            } else if (act == "edt3") {
                param.act = 4;
            }
            param.odid = this.orderInfos.id;
            https.copyReturnEdit(param, back);
            function back(data) {
                if (!data) return;
                if (data.status == 1) {
                    uni.$emit(
                        eventCtrl.COPY_RETURN_EDIT_EVENT,
                        staticConst.MD_KD
                    );
                }
            }
        },

        setBillListPageId(data) {
            this.removeEvent();
            this.billListPageId = data;
            this.addEvent();
        },

        /***注册事件****/
        addEvent() {
            uni.$on(eventCtrl.ORDER_LIST_EVENT, this.setBillListPageId);
        },

        removeEvent() {
            uni.$off(eventCtrl.ORDER_LIST_EVENT);
        },
    },

    mounted() {
        this.addEvent();
    },
};
</script>

<style lang="scss" scoped>
.web-view-box {
    height: 600px;
    .iframe-info {
        width: 100%;
        height: 100%;
        border: none;
    }
}
.isogisticsInfo-box {
    .but {
        text-align: right;
        padding-left: 20px;
    }
    .table-box {
        ::v-deep.supplierList {
            .el-table__body {
                .el-table__row {
                    cursor: pointer;
                }
            }
        }
        .table-box {
            margin-top: 20px;
            .operation-but {
                display: flex;
                justify-content: center;
                align-items: center;
            }
        }
    }
}
.logistics-cloud {
    .odd-numbers {
        padding-left: 23px;
    }
    .info-form {
        margin-top: 20px;
        .w-300 {
            width: 300px;
        }
    }
}
</style>
<style lang="scss">
.bills-info {
    flex: 1;
    margin-left: 345px;
    height: 100vh;
    .overflow-box {
        // margin-top: 40px;
        overflow-y: auto;
        height: calc(100vh - 293px);
        button {
            margin: 10px 0;
            background: #007aff;
            color: #fff;
            font-size: 20px;
        }
    }
    .overflow-box::-webkit-scrollbar {
        /*滚动条整体样式*/
        width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
        height: 0px;
    }
    .overflow-box::-webkit-scrollbar-thumb {
        /*滚动条里面小方块*/
        border-radius: 10px;
        -webkit-box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
        background: #ccc; //rgba(0, 0, 0, 0.0);
        scrollbar-arrow-color: red;
    }
    .overflow-box::-webkit-scrollbar-track {
        /*滚动条里面轨道*/
        -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0);
        border-radius: 0;
        background: rgba(0, 0, 0, 0);
    }

    .info-content {
        display: flex;
        justify-content: flex-start;
    }

    .b-info {
        // padding-right: 310px;
        // margin-right: 310px;
        width: 100%;
        border-right: 1px solid #ececec;
        background: #fff;
        .empty-p-style {
            padding-top: 110px;
        }
    }

    .c-info {
        // width: 310px;
        // height: 100%;
    }
}
</style>